#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

const int N = 2e5 + 10;

int n;
int q[N];

bool check(){
    
    LL cnt = 0;
    bool flag = false;
    for(int i = 1; i <= n; i ++){
        cnt += q[i];
        if(flag && cnt) return false;
        if(cnt < 0) return false;
        if(cnt == 0) flag = true;
    }

    if(cnt != 0){
        return false;
    }else{
        return true;
    }
}


void solve(){
    memset(q, 0, sizeof q);


    scanf("%d", &n);

    for(int i = 1; i <= n; i ++){
        scanf("%d", &q[i]);
    }

    if(check()){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    int T;
    scanf("%d", &T);
    while(T--){
        solve();
    }
    return 0;
}